/*********************************************************************************************
* File£º	AscII8x16.c
* Author:	embest	
* Desc£º	Ascii table in 8x16 dot lattice 
* History:	
*********************************************************************************************/
#include "typedef.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
/*------------------------------------------------------------------------------------------*/
/*	 								constant define						 				    */
/*------------------------------------------------------------------------------------------*/
#define G_AUC_ASCII_LEN 4096

const u8 g_ucAscii24x56[]= {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x06,0x00,0x0F,0x00,0x09,0x00,
0x19,0x80,0x10,0x80,0x30,0x80,0x30,0xC0,
0x30,0xC0,0x30,0xC0,0x20,0x40,0x20,0x40,
0x60,0x40,0x60,0x60,0x60,0x60,0x60,0x60,
0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,
0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,
0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,
0x60,0x40,0x20,0x40,0x20,0x40,0x30,0xC0,
0x30,0xC0,0x30,0xC0,0x10,0x80,0x10,0x80,
0x19,0x80,0x09,0x00,0x0F,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"0",0*/


0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x02,0x00,0x02,0x00,0x02,0x00,
0x0E,0x00,0x1E,0x00,0x06,0x00,0x06,0x00,
0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,
0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,
0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,
0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,
0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,
0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,
0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,
0x06,0x00,0x0F,0x00,0x1F,0xC0,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"1",1*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x06,0x00,0x0F,0x00,0x11,0x80,
0x30,0x80,0x20,0xC0,0x20,0xC0,0x20,0x40,
0x20,0x40,0x20,0x40,0x30,0x40,0x30,0x40,
0x30,0x40,0x20,0x40,0x00,0xC0,0x00,0xC0,
0x00,0xC0,0x00,0x80,0x00,0x80,0x01,0x80,
0x01,0x00,0x01,0x00,0x02,0x00,0x02,0x00,
0x06,0x00,0x04,0x00,0x04,0x00,0x08,0x00,
0x08,0x00,0x10,0x00,0x10,0x20,0x10,0x20,
0x20,0x40,0x20,0x40,0x20,0x40,0x40,0x40,
0x7F,0xC0,0x7F,0xC0,0x7F,0xC0,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"2",2*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x06,0x00,0x1F,0x00,0x11,0x00,
0x21,0x80,0x20,0x80,0x20,0x80,0x20,0xC0,
0x20,0xC0,0x30,0xC0,0x20,0xC0,0x20,0xC0,
0x00,0xC0,0x00,0xC0,0x00,0x80,0x00,0x80,
0x01,0x80,0x01,0x00,0x06,0x00,0x07,0x00,
0x01,0x00,0x00,0x80,0x00,0x80,0x00,0xC0,
0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40,
0x00,0x40,0x20,0x40,0x20,0x40,0x70,0x40,
0x70,0x40,0x60,0x40,0x20,0xC0,0x20,0xC0,
0x20,0x80,0x11,0x80,0x1F,0x00,0x04,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"3",3*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x80,0x01,0x80,0x01,0x80,
0x01,0x80,0x01,0x80,0x03,0x80,0x03,0x80,
0x03,0x80,0x05,0x80,0x05,0x80,0x05,0x80,
0x05,0x80,0x09,0x80,0x09,0x80,0x09,0x80,
0x11,0x80,0x11,0x80,0x11,0x80,0x11,0x80,
0x21,0x80,0x21,0x80,0x21,0x80,0x21,0x80,
0x41,0x80,0x41,0x80,0x7F,0xE0,0x7F,0xE0,
0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,
0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,
0x01,0x80,0x01,0x80,0x07,0xE0,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"4",4*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x1F,0xC0,0x3F,0xC0,
0x3F,0xC0,0x20,0x00,0x20,0x00,0x20,0x00,
0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,
0x20,0x00,0x20,0x00,0x20,0x00,0x27,0x00,
0x2F,0x80,0x29,0x80,0x30,0x80,0x30,0xC0,
0x20,0xC0,0x20,0x40,0x00,0x40,0x00,0x40,
0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40,
0x20,0x40,0x20,0x40,0x70,0x40,0x70,0x40,
0x60,0x40,0x20,0xC0,0x20,0xC0,0x20,0xC0,
0x20,0x80,0x11,0x80,0x0F,0x00,0x04,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"5",5*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x03,0x00,0x07,0x80,0x08,0x80,
0x18,0xC0,0x10,0xC0,0x10,0xC0,0x30,0xC0,
0x30,0x80,0x20,0x00,0x20,0x00,0x20,0x00,
0x20,0x00,0x60,0x00,0x60,0x00,0x63,0x00,
0x67,0x80,0x6D,0x80,0x68,0xC0,0x70,0xC0,
0x70,0x40,0x70,0x40,0x60,0x60,0x60,0x60,
0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,
0x60,0x60,0x60,0x60,0x20,0x60,0x20,0x60,
0x20,0x40,0x30,0x40,0x30,0x40,0x10,0xC0,
0x18,0x80,0x19,0x80,0x0F,0x00,0x02,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"6",6*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x3F,0xE0,0x3F,0xE0,
0x3F,0xC0,0x30,0x40,0x20,0x40,0x20,0x40,
0x20,0x80,0x40,0x80,0x40,0x80,0x00,0x80,
0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,
0x01,0x00,0x03,0x00,0x02,0x00,0x02,0x00,
0x02,0x00,0x02,0x00,0x02,0x00,0x06,0x00,
0x06,0x00,0x04,0x00,0x04,0x00,0x04,0x00,
0x04,0x00,0x04,0x00,0x0C,0x00,0x0C,0x00,
0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,
0x0C,0x00,0x0C,0x00,0x0C,0x00,0x04,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"7",7*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x06,0x00,0x1F,0x00,0x11,0x80,
0x30,0x80,0x20,0xC0,0x20,0x40,0x20,0x40,
0x60,0x40,0x60,0x40,0x60,0x40,0x60,0x40,
0x20,0x40,0x20,0x40,0x30,0x40,0x30,0xC0,
0x18,0x80,0x1D,0x80,0x0F,0x00,0x0F,0x00,
0x17,0x00,0x13,0x80,0x31,0x80,0x21,0xC0,
0x20,0xC0,0x60,0xC0,0x60,0x40,0x40,0x40,
0x40,0x60,0x40,0x60,0x40,0x60,0x40,0x60,
0x40,0x40,0x60,0x40,0x20,0x40,0x20,0x40,
0x30,0x80,0x11,0x80,0x0F,0x00,0x04,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"8",8*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x06,0x00,0x1F,0x00,0x11,0x80,
0x30,0x80,0x20,0x80,0x20,0xC0,0x20,0xC0,
0x60,0x40,0x60,0x40,0x60,0x40,0x60,0x40,
0x60,0x40,0x60,0x60,0x60,0x60,0x60,0x60,
0x60,0x60,0x60,0x60,0x60,0xE0,0x60,0xE0,
0x20,0xE0,0x31,0x60,0x31,0x60,0x1E,0x60,
0x0E,0x40,0x00,0x40,0x00,0x40,0x00,0x40,
0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,
0x20,0x80,0x30,0x80,0x31,0x80,0x31,0x80,
0x31,0x00,0x33,0x00,0x1E,0x00,0x08,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"9",9*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x30,0x00,0x30,0x00,0x30,0x00,
0x38,0x00,0x38,0x00,0x18,0x00,0x10,0x00,
0x10,0x00,0x10,0x00,0x10,0x00,0x30,0x00,
0x20,0x00,0x60,0x00,0x00,0x00,0x00,0x00,/*",",:*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x30,0x00,0x30,0x00,0x30,0x00,
0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*".",;*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x40,0x00,0x40,0x00,0x40,
0x00,0x80,0x00,0x80,0x01,0x00,0x01,0x00,
0x03,0x00,0x02,0x00,0x02,0x00,0x04,0x00,
0x04,0x00,0x08,0x00,0x08,0x00,0x18,0x00,
0x10,0x00,0x10,0x00,0x20,0x00,0x20,0x00,
0x20,0x00,0x20,0x00,0x10,0x00,0x10,0x00,
0x18,0x00,0x08,0x00,0x08,0x00,0x04,0x00,
0x04,0x00,0x02,0x00,0x02,0x00,0x03,0x00,
0x01,0x00,0x01,0x00,0x00,0x80,0x00,0x80,
0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"<",<*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x20,0x00,0x20,0x00,0x20,0x00,
0x10,0x00,0x10,0x00,0x08,0x00,0x08,0x00,
0x0C,0x00,0x04,0x00,0x04,0x00,0x02,0x00,
0x02,0x00,0x01,0x00,0x01,0x00,0x01,0x80,
0x00,0x80,0x00,0x80,0x00,0x40,0x00,0x40,
0x00,0x40,0x00,0x40,0x00,0x80,0x00,0x80,
0x01,0x80,0x01,0x00,0x01,0x00,0x02,0x00,
0x02,0x00,0x04,0x00,0x04,0x00,0x0C,0x00,
0x08,0x00,0x08,0x00,0x10,0x00,0x10,0x00,
0x20,0x00,0x20,0x00,0x20,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*">",=*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x6C,0xC0,0xFD,0xC0,
0x77,0x60,0x66,0x20,0x66,0x20,0x66,0x20,
0x66,0x20,0x66,0x20,0x66,0x20,0x66,0x20,
0x66,0x20,0x66,0x20,0x66,0x20,0x66,0x20,
0x66,0x20,0x66,0x20,0x66,0x20,0x66,0x20,
0x66,0x20,0x66,0x20,0x66,0x20,0x66,0x20,
0x66,0x20,0x66,0x60,0xEF,0x70,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"m",>*/

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xE0,0x70,0x60,0x60,
0x60,0xE0,0x60,0xE0,0x60,0xE0,0x60,0xE0,
0x70,0xE0,0x70,0xE0,0x70,0xE0,0x70,0xE0,
0x51,0x60,0x51,0x60,0x51,0x60,0x51,0x60,
0x51,0x60,0x51,0x60,0x51,0x60,0x59,0x60,
0x59,0x60,0x59,0x60,0x4A,0x60,0x4A,0x60,
0x4A,0x60,0x4A,0x60,0x4A,0x60,0x4A,0x60,
0x4A,0x60,0x4A,0x60,0x4C,0x60,0x4C,0x60,
0x4C,0x60,0x44,0x60,0x44,0x60,0x44,0x60,
0x44,0x60,0x44,0x60,0xE4,0xF0,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00/*"M",?*/
};
u32 g_dwLcdWidth24x56;
u32 g_dwLcdHeight24x56;
u32 g_pLCDBuffer24x56;

static void PutTFT16Bit_480640_24x56(u32 x,u32 y, u32 c)
{
	// RGB24
    if(x<(g_dwLcdWidth24x56) && y<(g_dwLcdHeight24x56))
        memcpy((unsigned char*)(g_pLCDBuffer24x56 + (x+y*g_dwLcdWidth24x56)*4), (unsigned char*)&c, 4);
}
#if 0
void LCDDisplayASCII24x24(u32 x0, u32 y0, u32 ForeColor, char * s)
{
	u32 i,j,k,x,y,xx;
	u8 qm;
	u32 ulOffset;
	u32 ywbuf[36],temp[2];
	u32 tmp;
    
	for(i = 0; i < strlen((const char*)s); i++)
	{
		if(((u8)*(s+i) >= 127) || (((u8)*(s+i) <= 31)))
		{
			temp[0] = *(s + i);
			temp[1] = '\0';
			return;
		}
		else
		{
			qm = *(s+i);
			qm -= 0x30;
    		ulOffset = (u32)(qm) * 72;	
    		for (j = 0; j < 24; j ++)
    		{
			tmp = j*3;
    			ywbuf[j] = (g_ucAscii24x24[ulOffset + tmp] << 16) |  (g_ucAscii24x24[ulOffset + tmp + 1] << 8) | g_ucAscii24x24[ulOffset + tmp + 2];
    		}

    		for(y = 0; y < 24; y++)
    		{
       		    for(x = 0; x < 24; x++) 
       		    {
           			k = x % 24;
	       			if (ywbuf[y]  & (0x800000 >> k))
	       			{
	       				xx = x0 + x + i*24;
	       				PutTFT16Bit_480640_24x56( xx, y + y0, ForeColor);
	       			}
	   		    }
    	    }
         }
    }
}

#endif

void LCDDisplayASCII24x56(u32 x0, u32 y0, u32 ForeColor, char * s)
{
	u32 i,j,k,x,y,xx;
	u8 qm;
	u32 ulOffset;
	u32 ywbuf[64],temp[2];
	u32 tmp;
	u32 tmp1;
	
		
	for(i = 0; i < strlen((const char*)s); i++)
	{
		if(((u8)*(s+i) >= 127) || (((u8)*(s+i) <= 31)))
		{
			temp[0] = *(s + i);
			temp[1] = '\0';
			return;
		}
		else
		{
			qm = *(s+i);
			if(*(s+i)==0x2C){				
				qm += 0x0E;			
			}
			else if(*(s+i)==0x2E){
				qm += 0x0D;				
			}
			else if(*(s+i)==0x3E){			
				qm -= 0x01;
			}
			else if(*(s+i)==0x6d){
				qm -= 0x2F;
			}
			else if(*(s+i)==0x4d){
				qm -= 0x0E;
			}			
			qm -= 0x30;
			
    		ulOffset = (u32)(qm) * 112;	
    		for (j = 0; j < 56; j ++)
    		{
				tmp = j*2;
    			ywbuf[j] = (g_ucAscii24x56[ulOffset + tmp ] << 8) | g_ucAscii24x56[ulOffset + tmp + 1];
				
			}

    		for(y = 0; y < 56; y++)
    		{
       		    for(x = 0; x < 24; x++) 
       		    {
           			k = x % 24;
	       			if (ywbuf[y]  & (0x800000 >> k))
	       			{
	       				xx = x0 + x + i*24;
	       				PutTFT16Bit_480640_24x56( xx, y + y0, ForeColor);
	       			}
	   		    }
    	    }
         }
		 ///////////////
			
			
    }
	
}

